package com.timmy.google_play.factory;

import com.timmy.google_play.proxy.ThreadPoolProxy;

/**
 * Created by Timmy on 2016/12/12.
 */

public class ThreadPoolProxyFactory {

    static ThreadPoolProxy mNormalThreadPoolProxy;
    static ThreadPoolProxy mDownloadThreadPoolProxy;


    /**
     * 得到普通的线程池代理对象
     */
    public static ThreadPoolProxy getNormalThreadPoolProxy() {

        //双重锁
        if (mNormalThreadPoolProxy == null) {
            synchronized (ThreadPoolProxyFactory.class) {
                if (mNormalThreadPoolProxy == null) {
                    mNormalThreadPoolProxy = new ThreadPoolProxy(5);
                }
            }
        }
        return mNormalThreadPoolProxy;
    }

    /**
     * 得到下载的线程池代理对象
     */
    public static ThreadPoolProxy getDownloadThreadPoolProxy() {

        //双重锁
        if (mDownloadThreadPoolProxy == null) {
            synchronized (ThreadPoolProxyFactory.class) {
                if (mDownloadThreadPoolProxy == null) {
                    mDownloadThreadPoolProxy = new ThreadPoolProxy(3);
                }
            }
        }
        return mDownloadThreadPoolProxy;
    }
}
